var Page = function(){
    this.init();
};
Page.prototype = {
    params: {

    },
    init: function(){

        this.initEvent();
    },
    accountLogin: function(){
        var _this = this;
        var account = $('#account').val(),
            password = $('#password').val();
        if(!account){
            layui.use('layer', function () {
                var layer = layui.layer;
                setTimeout(function(){
                    layer.msg('请输入账号');
                },10)
            });
        }else if(!password){
            layui.use('layer', function () {
                var layer = layui.layer;
                layer.msg('请输入密码');
            });
        }else{
            var paramsObj = {
                loginAccount: account,
                loginPassword: password
            };
            Api.login(paramsObj, function(data){
                layer.msg('登录成功', {icon: 6});
                // var reLink = Pub.getCookie('return-link'),link;
                // if(reLink){
                //     link = reLink;
                // }else{
                     link = Pub.getHtmlUrl('./index.html');
                // }
                Pub.setCookie('_PASSPORT', data.passport);
                setTimeout(function(){
                      window.location.href = link;

                }, 1500);
            });
        }
    },
    clickEvent: function(){
        var _this = this;
        $('#btn_login').on('click', function(){
            _this.accountLogin();
        });
        $(document).keydown(function(event){
            if(event.keyCode==13){
               _this.accountLogin();
            }
         });
    },
    initEvent: function(){
        var _this = this;
        _this.clickEvent();
    }
};
var page = new Page();